import { useTranslate } from "@tolgee/react";
import { BasicSelect } from "@/components/inputs/BasicSelect";

type Props = {
  countryCode?: string;
  onSelect: (countryCode: string | undefined) => void;
};

export const CountryCodeSelect = ({ countryCode, onSelect }: Props) => {
  const { t } = useTranslate();
  const handleOnChange = (
    value: (typeof countries)[number]["value"] | undefined,
  ) => {
    onSelect(value);
  };
  return (
    <BasicSelect
      placeholder={t(
        "blocks.inputs.phone.settings.international.placeholder.label",
      )}
      value={countryCode}
      onChange={handleOnChange}
      items={countries}
    />
  );
};

const countries = [
  { label: "Algeria (+213)", value: "DZ" },
  { label: "Andorra (+376)", value: "AD" },
  { label: "Angola (+244)", value: "AO" },
  { label: "Anguilla (+1264)", value: "AI" },
  { label: "Antigua &amp; Barbuda (+1268)", value: "AG" },
  { label: "Argentina (+54)", value: "AR" },
  { label: "Armenia (+374)", value: "AM" },
  { label: "Aruba (+297)", value: "AW" },
  { label: "Australia (+61)", value: "AU" },
  { label: "Austria (+43)", value: "AT" },
  { label: "Azerbaijan (+994)", value: "AZ" },
  { label: "Bahamas (+1242)", value: "BS" },
  { label: "Bahrain (+973)", value: "BH" },
  { label: "Bangladesh (+880)", value: "BD" },
  { label: "Barbados (+1246)", value: "BB" },
  { label: "Belarus (+375)", value: "BY" },
  { label: "Belgium (+32)", value: "BE" },
  { label: "Belize (+501)", value: "BZ" },
  { label: "Benin (+229)", value: "BJ" },
  { label: "Bermuda (+1441)", value: "BM" },
  { label: "Bhutan (+975)", value: "BT" },
  { label: "Bolivia (+591)", value: "BO" },
  { label: "Bosnia Herzegovina (+387)", value: "BA" },
  { label: "Botswana (+267)", value: "BW" },
  { label: "Brazil (+55)", value: "BR" },
  { label: "British Indian Ocean Territory (+246)", value: "IO" },
  { label: "Brunei (+673)", value: "BN" },
  { label: "Bulgaria (+359)", value: "BG" },
  { label: "Burkina Faso (+226)", value: "BF" },
  { label: "Burundi (+257)", value: "BI" },
  { label: "Cambodia (+855)", value: "KH" },
  { label: "Cameroon (+237)", value: "CM" },
  { label: "Canada (+1)", value: "CA" },
  { label: "Cape Verde Islands (+238)", value: "CV" },
  { label: "Cayman Islands (+1345)", value: "KY" },
  { label: "Central African Republic (+236)", value: "CF" },
  { label: "Chile (+56)", value: "CL" },
  { label: "China (+86)", value: "CN" },
  { label: "Colombia (+57)", value: "CO" },
  { label: "Comoros (+269)", value: "KM" },
  { label: "Congo (+242)", value: "CG" },
  { label: "Cook Islands (+682)", value: "CK" },
  { label: "Costa Rica (+506)", value: "CR" },
  { label: "Cote D'Ivoire (+225)", value: "CI" },
  { label: "Croatia (+385)", value: "HR" },
  { label: "Cuba (+53)", value: "CU" },
  { label: "Cyprus North (+90392)", value: "CY" },
  { label: "Cyprus South (+357)", value: "CY" },
  { label: "Czech Republic (+42)", value: "CZ" },
  { label: "Denmark (+45)", value: "DK" },
  { label: "Djibouti (+253)", value: "DJ" },
  { label: "Dominica (+1809)", value: "DM" },
  { label: "Dominican Republic (+18XX)", value: "DO" },
  { label: "Ecuador (+593)", value: "EC" },
  { label: "Egypt (+20)", value: "EG" },
  { label: "El Salvador (+503)", value: "SV" },
  { label: "Equatorial Guinea (+240)", value: "GQ" },
  { label: "Eritrea (+291)", value: "ER" },
  { label: "Estonia (+372)", value: "EE" },
  { label: "Ethiopia (+251)", value: "ET" },
  { label: "Falkland Islands (+500)", value: "FK" },
  { label: "Faroe Islands (+298)", value: "FO" },
  { label: "Fiji (+679)", value: "FJ" },
  { label: "Finland (+358)", value: "FI" },
  { label: "France (+33)", value: "FR" },
  { label: "French Guiana (+594)", value: "GF" },
  { label: "French Polynesia (+689)", value: "PF" },
  { label: "Gabon (+241)", value: "GA" },
  { label: "Gambia (+220)", value: "GM" },
  { label: "Georgia (+7880)", value: "GE" },
  { label: "Germany (+49)", value: "DE" },
  { label: "Ghana (+233)", value: "GH" },
  { label: "Gibraltar (+350)", value: "GI" },
  { label: "Greece (+30)", value: "GR" },
  { label: "Greenland (+299)", value: "GL" },
  { label: "Grenada (+1473)", value: "GD" },
  { label: "Guadeloupe (+590)", value: "GP" },
  { label: "Guam (+671)", value: "GU" },
  { label: "Guatemala (+502)", value: "GT" },
  { label: "Guinea (+224)", value: "GN" },
  { label: "Guinea - Bissau (+245)", value: "GW" },
  { label: "Guyana (+592)", value: "GY" },
  { label: "Haiti (+509)", value: "HT" },
  { label: "Honduras (+504)", value: "HN" },
  { label: "Hong Kong (+852)", value: "HK" },
  { label: "Hungary (+36)", value: "HU" },
  { label: "Iceland (+354)", value: "IS" },
  { label: "India (+91)", value: "IN" },
  { label: "Indonesia (+62)", value: "ID" },
  { label: "Iran (+98)", value: "IR" },
  { label: "Iraq (+964)", value: "IQ" },
  { label: "Ireland (+353)", value: "IE" },
  { label: "Israel (+972)", value: "IL" },
  { label: "Italy (+39)", value: "IT" },
  { label: "Jamaica (+1876)", value: "JM" },
  { label: "Japan (+81)", value: "JP" },
  { label: "Jordan (+962)", value: "JO" },
  { label: "Kazakhstan (+7)", value: "KZ" },
  { label: "Kenya (+254)", value: "KE" },
  { label: "Kiribati (+686)", value: "KI" },
  { label: "Korea North (+850)", value: "KP" },
  { label: "Korea South (+82)", value: "KR" },
  { label: "Kuwait (+965)", value: "KW" },
  { label: "Kyrgyzstan (+996)", value: "KG" },
  { label: "Laos (+856)", value: "LA" },
  { label: "Latvia (+371)", value: "LV" },
  { label: "Lebanon (+961)", value: "LB" },
  { label: "Lesotho (+266)", value: "LS" },
  { label: "Liberia (+231)", value: "LR" },
  { label: "Libya (+218)", value: "LY" },
  { label: "Liechtenstein (+417)", value: "LI" },
  { label: "Lithuania (+370)", value: "LT" },
  { label: "Luxembourg (+352)", value: "LU" },
  { label: "Macao (+853)", value: "MO" },
  { label: "Macedonia (+389)", value: "MK" },
  { label: "Madagascar (+261)", value: "MG" },
  { label: "Malawi (+265)", value: "MW" },
  { label: "Malaysia (+60)", value: "MY" },
  { label: "Maldives (+960)", value: "MV" },
  { label: "Mali (+223)", value: "ML" },
  { label: "Malta (+356)", value: "MT" },
  { label: "Marshall Islands (+692)", value: "MH" },
  { label: "Martinique (+596)", value: "MQ" },
  { label: "Mauritania (+222)", value: "MR" },
  { label: "Mayotte (+269)", value: "YT" },
  { label: "Mexico (+52)", value: "MX" },
  { label: "Micronesia (+691)", value: "FM" },
  { label: "Moldova (+373)", value: "MD" },
  { label: "Monaco (+377)", value: "MC" },
  { label: "Mongolia (+976)", value: "MN" },
  { label: "Montserrat (+1664)", value: "MS" },
  { label: "Morocco (+212)", value: "MA" },
  { label: "Mozambique (+258)", value: "MZ" },
  { label: "Myanmar (+95)", value: "MM" },
  { label: "Namibia (+264)", value: "NA" },
  { label: "Nauru (+674)", value: "NR" },
  { label: "Nepal (+977)", value: "NP" },
  { label: "Netherlands (+31)", value: "NL" },
  { label: "New Caledonia (+687)", value: "NC" },
  { label: "New Zealand (+64)", value: "NZ" },
  { label: "Nicaragua (+505)", value: "NI" },
  { label: "Niger (+227)", value: "NE" },
  { label: "Nigeria (+234)", value: "NG" },
  { label: "Niue (+683)", value: "NU" },
  { label: "Norfolk Islands (+672)", value: "NF" },
  { label: "Northern Marianas (+670)", value: "MP" },
  { label: "Norway (+47)", value: "NO" },
  { label: "Oman (+968)", value: "OM" },
  { label: "Palau (+680)", value: "PW" },
  { label: "Panama (+507)", value: "PA" },
  { label: "Papua New Guinea (+675)", value: "PG" },
  { label: "Paraguay (+595)", value: "PY" },
  { label: "Peru (+51)", value: "PE" },
  { label: "Philippines (+63)", value: "PH" },
  { label: "Poland (+48)", value: "PL" },
  { label: "Portugal (+351)", value: "PT" },
  { label: "Puerto Rico (+1787)", value: "PR" },
  { label: "Qatar (+974)", value: "QA" },
  { label: "Reunion (+262)", value: "RE" },
  { label: "Romania (+40)", value: "RO" },
  { label: "Russia (+7)", value: "RU" },
  { label: "Rwanda (+250)", value: "RW" },
  { label: "San Marino (+378)", value: "SM" },
  { label: "Sao Tome &amp; Principe (+239)", value: "ST" },
  { label: "Saudi Arabia (+966)", value: "SA" },
  { label: "Senegal (+221)", value: "SN" },
  { label: "Serbia (+381)", value: "CS" },
  { label: "Seychelles (+248)", value: "SC" },
  { label: "Sierra Leone (+232)", value: "SL" },
  { label: "Singapore (+65)", value: "SG" },
  { label: "Slovak Republic (+421)", value: "SK" },
  { label: "Slovenia (+386)", value: "SI" },
  { label: "Solomon Islands (+677)", value: "SB" },
  { label: "Somalia (+252)", value: "SO" },
  { label: "South Africa (+27)", value: "ZA" },
  { label: "Spain (+34)", value: "ES" },
  { label: "Sri Lanka (+94)", value: "LK" },
  { label: "Sudan (+249)", value: "SD" },
  { label: "Suriname (+597)", value: "SR" },
  { label: "Swaziland (+268)", value: "SZ" },
  { label: "Sweden (+46)", value: "SE" },
  { label: "Switzerland (+41)", value: "CH" },
  { label: "Syria (+963)", value: "SY" },
  { label: "Taiwan (+886)", value: "TW" },
  { label: "Tajikistan (+992)", value: "TJ" },
  { label: "Tanzania (+255)", value: "TZ" },
  { label: "Thailand (+66)", value: "TH" },
  { label: "Togo (+228)", value: "TG" },
  { label: "Tokelau (+690)", value: "TK" },
  { label: "Tonga (+676)", value: "TO" },
  { label: "Trinidad &amp; Tobago (+1868)", value: "TT" },
  { label: "Tunisia (+216)", value: "TN" },
  { label: "Turkey (+90)", value: "TR" },
  { label: "Turkmenistan (+993)", value: "TM" },
  { label: "Turks &amp; Caicos Islands (+1649)", value: "TC" },
  { label: "Tuvalu (+688)", value: "TV" },
  { label: "Uganda (+256)", value: "UG" },
  { label: "Ukraine (+380)", value: "UA" },
  { label: "United Arab Emirates (+971)", value: "AE" },
  { label: "United Kingdom (+44)", value: "GB" },
  { label: "United States (+1)", value: "US" },
  { label: "United States Minor Outlying Islands (+1)", value: "UM" },
  { label: "Uruguay (+598)", value: "UY" },
  { label: "Uzbekistan (+998)", value: "UZ" },
  { label: "Vanuatu (+678)", value: "VU" },
  { label: "Venezuela (+58)", value: "VE" },
  { label: "Vietnam (+84)", value: "VN" },
  { label: "Virgin Islands (British (+1284)", value: "VG" },
  { label: "Virgin Islands (U.S. (+1340)", value: "VI" },
  { label: "Wallis &amp; Futuna (+681)", value: "WF" },
  { label: "Yemen (+967)", value: "YE" },
  { label: "Zambia (+260)", value: "ZM" },
  { label: "Zimbabwe (+263)", value: "ZW" },
];
